define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vacant/index' + location.search,
                    year_url: 'vacant/year' + location.search,
                    add_url: 'vacant/add',
                    edit_url: 'vacant/edit',
                    del_url: 'vacant/del',
                    multi_url: 'vacant/multi',
                    import_url: 'vacant/import',
                    table: 'vacant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        // {field: 'user_id', title: __('User_id')},
                        {field: 'total_num', title: __('总房源'),operate:false},
                        {field: 'rent_num', title: __('已出租数'),operate:false},
                        {field: 'rate', title: __('Rate'), operate:false},
                        {field: 'year', title: __('年')},
                        {field: 'month', title: __('月'), operate: false},
                        {field: 'day', title: __('日'), operate:false},
                        // {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        // {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        year: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vacant/year' + location.search,
                    add_url: 'vacant/add',
                    edit_url: 'vacant/edit',
                    del_url: 'vacant/del',
                    multi_url: 'vacant/multi',
                    import_url: 'vacant/import',
                    table: 'vacant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},

                        {field: 'year', title: __('年份'),operate:false},
                        {field: 'pay', title: __('已收'),operate:false},
                        {field: 'un_pay', title: __('待收'),operate:false},
                        {field: 'total_money', title: __('合计'),operate:false},
                        // {field: 'rent_num', title: __('已出租数'),operate:false},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        month: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vacant/month' + location.search,
                    add_url: 'vacant/add',
                    edit_url: 'vacant/edit',
                    del_url: 'vacant/del',
                    multi_url: 'vacant/multi',
                    import_url: 'vacant/import',
                    table: 'vacant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},

                        {field: 'month', title: __('月份'),operate:false},
                        {field: 'pay', title: __('已收'),operate:false},
                        {field: 'un_pay', title: __('待收'),operate:false},
                        {field: 'total_money', title: __('合计'),operate:false},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        day: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vacant/day' + location.search,
                    add_url: 'vacant/add',
                    edit_url: 'vacant/edit',
                    del_url: 'vacant/del',
                    multi_url: 'vacant/multi',
                    import_url: 'vacant/import',
                    table: 'vacant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},

                        {field: 'day', title: __('日'),operate:false},
                        {field: 'pay', title: __('已收'),operate:false},
                        {field: 'un_pay', title: __('待收'),operate:false},
                        // {field: 'type', searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'total_money', title: __('合计'),operate:false},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        shuidian: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vacant/shuidian' + location.search,
                    add_url: 'vacant/add',
                    edit_url: 'vacant/edit',
                    del_url: 'vacant/del',
                    multi_url: 'vacant/multi',
                    import_url: 'vacant/import',
                    table: 'vacant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},

                        // {field: 'name', title: __('类型'),operate:false},
                        {field: 'type', title: __('类型'), searchList: {"1":__('水表'),"2":__('电表'),"3":__('燃气'),"4":__('热水')}, formatter: Table.api.formatter.status},
                        {field: 'month', title: __('月份'),operate:false},
                        {field: 'total_use_num', title: __('总用量'),operate:false},
                        {field: 'total_money', title: __('总金额'),operate:false},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        project: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vacant/project' + location.search,
                    add_url: 'vacant/add',
                    edit_url: 'vacant/edit',
                    del_url: 'vacant/del',
                    multi_url: 'vacant/multi',
                    import_url: 'vacant/import',
                    table: 'vacant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},

                        {field: 'category', title: __('项目名称'),operate:false},
                        {field: 'month', title: __('月份'),operate:false},
                        // {field: 'total_use_num', title: __('总用量'),operate:false},
                        {field: 'total_money', title: __('总金额'),operate:false},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        yajin: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vacant/yajin' + location.search,
                    add_url: 'vacant/add',
                    edit_url: 'vacant/edit',
                    del_url: 'vacant/del',
                    multi_url: 'vacant/multi',
                    import_url: 'vacant/import',
                    table: 'vacant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},

                        {field: 'build_address', title: __('楼栋地址'),operate:false},
                        {field: 'room_name', title: __('房间'),operate:false},
                        {field: 'expire_date', title: __('租房日期'),operate:false},
                        {field: 'remark', title: __('备注'),operate:false},
                        {field: 'money', title: __('金额'),operate:false},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
